<template>
	<view class="content">
		<mescroll-uni ref="mescrollRef" @init="mescrollInit"  @up="upCallback" :up="upOption" :down="{use: false}">
			<view class="section-0">
				<view class="section-body">
					<view class="item" v-for="(item, idx) in board" @click="go(item)" :key="item.name">
						<view class="shape" v-if="item.right"></view>
						<view class="top">{{item.name}}</view>
						<view class="bottom">{{total[idx]}}</view>
					</view>
				</view>
			</view>
			<view class="section-1">
				<view class="list">
					<view :class="`item ${expandList.indexOf(item.id) !== -1 ? 'item__expand' : ''}`" v-for="item in list" :key="item.name">
						<view class="parent">
							<view class="name">
								{{item.project_name}}
							</view>
							<!-- <view class="action" @click="expandChange(item.id)">
								<view class="iconfont icon-xiala"></view>
							</view> -->
							<view class="info">
								<text style="min-width: 100%;">地址：{{item.dk_address}}</text>
								<text>进场：{{item.dk_time_in}}</text>
								<text>出场：{{item.dk_time_out}}</text>
								<!-- <text>{{item.user_name}}  {{item.lz_time}}</text>
								<text>履职时长  {{item.lz_duration}}</text>
								<text>问题次数  {{item.lz_duration}}</text>
								<text>检查时长  {{item.lz_duration}}</text>
								<text>会议次数  {{item.lz_duration}}</text>
								<text>会议时长  {{item.lz_duration}}</text> -->
							</view>
						</view>
						<!-- <view class="child" v-if="expandList.indexOf(item.id) !== -1">
							<view class="child-item" v-for="item2 in item.childern" :key="item2.id">
								<view class="top">
									<view class="info">
										<text>现场发现问题  11</text>
										<text>检测时长  10</text>
										<text>会议时长  5</text>
									</view>
									<view class="imgs">
										<view class="img">
											<text class="label">会议照片</text>
										</view>
										<view class="img">
											<text class="label">战班会照片</text>
										</view>
										<view class="img">
											<text class="label">检查问题</text>
										</view>
										<view class="img">
											<text class="label">考勤</text>
										</view>
									</view>
								</view>
							</view>
						</view> -->
					</view>
				</view>
			</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex';
	import { performDetailApi, performSignDetailApi } from '@/api/statistics.js';
	export default {
		data() {
			return {
				mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
				upOption:{
					textNoMore: '-- 没有更多了 --'
				},
				pageSize:20,
				name: '',
				board: [
					{ name: '履职次数', right: true, path: ''},
					{ name: '问题总数', right: true,},
					{ name: '会议总数' },
					// {name: '颗粒度履职',count: 0,},
				],
				list: [],
				expandList: [0],
				user_name: '',
				type: 1,
				total: [0, 0, 0]
			};
		},
		computed: {
			...mapGetters({start_time: 'duty/getStartTime', end_time: 'duty/getEndTime'}),
		},
		onLoad(data) {
			console.log(data,111);
			this.user_name = data.user_name;
			this.type = data.type
			this.total = data.total ? data.total.split(',') : [0, 0, 0]
		},
		onReady() {
			console.log(this.params, 'params');			
		},
		methods: {
			go(item) {
				if (item.name === '问题总数') {
					const params = {
						user_name: this.user_name,
						time_type: this.type,
					}
					uni.navigateTo({
						url: '/pages/statistics/comprehensive/duty/problem/info/index?params=' + JSON.stringify(params)
					})
				}
				if (item.name === '会议总数') {
					uni.navigateTo({
						url: `/pages/statistics/comprehensive/duty/meeting/list/index?nick_name=${this.user_name}&time_type=${this.type}`
					})
				}
			},
			expandChange(id) {
				const idx = this.expandList.indexOf(id);
				if (idx !== -1) {
					this.expandList.splice(idx, 1);
				} else {
					this.expandList.push(id);
				}
			},
			/*mescroll组件初始化的回调,可获取到mescroll对象 (此处可删,mixins已默认)*/
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*上拉加载的回调*/
			async upCallback(page) {
				const {data} =  await performSignDetailApi({
					user_name: this.user_name,
					start_time: this.start_time,
					end_time: this.end_time,
					page: page.num,
					pageSize: this.pageSize,
					time_type: this.type
				});
				if (data.code === 1 || data.code === 200) {
					// 接口返回的当前页数据列表 (数组)
					let curPageData = data.data.data; 
					// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
					let curPageLen = curPageData.length; 
					// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
					let totalPage = data.data.last_page; 
					//设置列表数据
					if(page.num == 1) this.list = []; //如果是第一页需手动置空列表
					this.list = this.list.concat(curPageData); //追加新数据
					// 请求成功,隐藏加载状态
					this.mescroll.endByPage(curPageLen, totalPage); 
					setTimeout(()=>{
						this.mescroll.endSuccess(curPageLen);
					},20);
				} else{
					//  请求失败,隐藏加载状态
					this.mescroll.endErr()
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #fff;
	}
	.section-1 {
		position: relative;
		top: -50rpx;
		z-index: 10;
		background-color: #fff;
		border-top-left-radius: 50rpx;
		border-top-right-radius: 50rpx;
		.list{
				width: 670rpx;
				box-sizing: border-box;
				margin-left: 40rpx;
				.item{
					width: 100%;
					border-bottom: solid 2rpx #f2f2f0;
					.parent{
						width: 100%;
						padding: 28rpx 0;
						@include clear();
						.info{
							width: 100%;
							float: left;
							line-height: 24prx;
							font-size: 16rpx;
							color: #7f98ae;
						
							text{
								display: inline-block;
								min-width: 50%;
								&:last-child{
									margin-right: 0;
								}
							}
						}
						.name{
							width: 100%;
							line-height: 30rpx;
							margin-bottom: 10rpx;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							line-height: 40rpx;
							letter-spacing: 2rpx;
							color: #3b3c40;
							// text-overflow: ellipsis;
							// overflow: hidden;
							// white-space: nowrap;
							float: left;
						}
						.action{
							float: right;
							width: 32rpx;
							height: 100%;
							line-height: 45rpx;
							text-align: center;
							color: #3b3c40;
							.iconfont{
								font-size: 32rpx;
								transition: 0.2s ease;
							}
			
						}
					}
					.child{
						width: 750rpx;
						margin-left: - 40rpx;
						background: #f2f2fa;
						.child-item{
							width: 670rpx;
							margin-left: 40rpx;
							border-bottom: 2rpx solid #e3e8f5;
							&:last-child{
								border-bottom: none;
							}
							.top{
								width: 100%;
								overflow: hidden;
								padding-top: 25rpx;
								padding-bottom: 25rpx;
								.info{
									width: 100%;
									float: left;
									height: 24rpx;
									line-height: 24prx;
									font-size: 16rpx;
									color: #7f98ae;
									margin-bottom: 20rpx;
									text{
										margin-right: 30rpx;
										&:last-child{
											margin-right: 0;
										}
									}
								}
								.imgs{
									width: 100%;
									flex-wrap: nowrap;
									display: flex;
									justify-content: space-between;
									.img{
										width: 150rpx;
										height: 42rpx;
										background-color: #ffffff;
										border-radius: 21rpx;
										text-align: center;
										line-height: 42rpx;
										font-size: 16rpx;
										font-weight: bold;
										font-stretch: normal;
										letter-spacing: 0rpx;
										color: #1534ce;
										box-shadow: 0 0 30rpx 8rpx rgba(#bcbcb5, 0.17);
										// .label{
										// 	margin-left: 10rpx;
										// 	margin-right: 20rpx;
										// }
										.iconfont{
											font-size: 16rpx;
											color: #1534ce;
										}
									}
								}
							}
						}
					}
				}
				.item__expand{
					.parent{
						.action{
							.iconfont{
								transform: rotate(-180deg);
							}
						}
					}
					.child{
						box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(0, 0, 0, 0.03) inset;
					}
				}
			
		}

		.actions {
			width: 100%;
			height: 50rpx;
			margin-top: 29rpx;
			padding-bottom: 40rpx;
			display: flex;
			justify-content: space-between;

			.action {
				width: 288rpx;
				height: 48rpx;
				background-color: #395cf5;
				border-radius: 20rpx;
				text-align: center;
				line-height: 48rpx;
				font-size: 26rpx;
				font-weight: normal;
				font-stretch: normal;
				color: #ffffff;

				text {
					&:first-child {
						margin-right: 20rpx;
					}
				}
			}

			.search {
				background-color: #1534ce;
			}
		}

		.form {
			width: 100%;
			padding: 0 75rpx;
			padding-top: 40rpx;
			box-sizing: border-box;

			.form-item {
				width: 600rpx;
				height: 48rpx;
				border-radius: 20rpx;
				border: solid 2rpx #1534ce;
				margin: 0 auto;
				margin-bottom: 34rpx;
				@include clear();

				.label {
					float: left;
					width: 134rpx;
					height: 48rpx;
					text-align: center;
					line-height: 44rpx;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #1534ce;
				}

				.shape {
					width: 3rpx;
					height: 32rpx;
					background-color: #7f98ae;
					float: left;
					margin-top: 8rpx;
				}

				.input {
					float: left;
					width: calc(100% - 134rpx - 3rpx);

					.input-body {
						box-sizing: border-box;
						width: 100%;
						height: 44rpx;
						padding: 0 !important;
						border: none;
						padding-left: 30rpx !important;
						padding-right: 30rpx !important;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: rgba(0, 0, 0, 0.7);
					}

					.input-placeholder {
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: rgba(0, 0, 0, 0.5);
					}
				}
			}
		}
	}

	.section-0 {
		width: 100%;
		background-color: #2e5efe;

		.section-body {
			width: 100%;
			padding-left: 40rpx;
			height: 230rpx;
			padding-right: 40rpx;
			padding-bottom: 50rpx;
			background-color: #1534ce;
			background-size: cover;
			background-repeat: no-repeat;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			overflow: hidden;
			box-sizing: border-box;

			.item {
				width: 33.33%;
				float: left;
				display: flex;
				flex-wrap: wrap;
				align-content: space-between;
				padding-top: 40rpx;
				height: 100rpx;
				position: relative;

				.shape {
					width: 4rpx;
					height: 84rpx;
					background-image: linear-gradient(rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%, );
					position: absolute;
					right: 0;
					top: 48rpx;
				}

				.top {
					width: 100%;
					text-align: center;
					font-size: 16rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #95c4fa;
				}

				.bottom {
					width: 100%;
					text-align: center;
					font-size: 58rpx;
					font-weight: bold;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #ffde00;
				}
			}
		}
	}
</style>
